<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>多图片上传系统</title>
<base target="_self">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style type="text/css">
body{
 font-size:12px;	
}
input{ border: 1px solid; background-color: #F9FBFB; border-color: #CCCCCC #EFEFEF #EFEFEF #CCCCCC; color: #666; vertical-align: middle; height: 25px;line-height: 20px; margin-left:5px;font-size:12px;}


</style>

<load href="__PUBLIC__/Js/jquery.js"/>
<load href="__PUBLIC__/Js/inc.js"/>
<script language="javascript">
$(function(){
   var flag=0;
   var v=window.dialogArguments;
   var pic_arr=[];
   var link_arr=[];
   var text_arr=[];
   var org_filename=[];
   if(!empty(v)){
      //如果不为空,则是修改
      if(v.indexOf("@")!=-1){
	     var arr=v.split("@");
		 pic_arr=arr[0].split(",");
		 text_arr=arr[1].split(",");
		 link_arr=arr[2].split(",");
		 if(arr[3]==undefined) arr[3]="";
		 org_filename = arr[3].split(",");

		 var add_input_num=arr[0].split(",").length-1;
		 for(var i=1;i<=add_input_num;i++){
		    var l=$("#content > tbody > tr").length;
			var pos = l -2;
            $("#content > tbody > tr:eq(1)").clone().insertAfter("#content > tbody > tr:eq("+pos+")");
		 }
		 $("img[name='thumb']").each(function(i){
			  $(this).attr("src","__ROOT__/"+pic_arr[i]);
			  $(this).parent().next().find("input[name='pic_path']").val(pic_arr[i]);
			  $("input[name='pic_text']").eq(i).val(text_arr[i]);
			  $("input[name='pic_link']").eq(i).val(link_arr[i]);
			  if({$Think.get.is_show_org_filename}==1){
				  $(this).prev("span").text(org_filename[i]);  
			  }
		 });
		 pic_arr=[];
		 text_arr=[];
		 link_arr=[];
		 org_filename=[];
	  }
   }
   $("#add").bind("click",function(event){
        var l=$("#content > tbody > tr").length;
		var pos = l-2;
        $("#content > tbody > tr:eq(1)").clone().insertAfter("#content > tbody > tr:eq("+pos+")");
   });
   //返回
   $("#back_btn").bind("click",function(event){
       $("input[name='pic_path']").each(function(i){
	      if($(this).val()!=''){flag=1;return false}
	   });
	   if(!flag){alert('请至少上传一张图片');return false;}
	   $("#add").attr("disabled",false);
	   $(this).attr("disabled",false);
	   $("input[name='pic_path']").each(function(i){
	        pic_arr.push($(this).val());
			link_arr.push($("input[name='pic_link']").eq(i).val());
			text_arr.push($("input[name='pic_text']").eq(i).val());
			org_filename.push($(this).parent().prev().find("span").text());
	   });
	   pic_str=pic_arr.join(",");
	   link_str=link_arr.join(",");
	   text_str=text_arr.join(",");
	   org_filename_str=org_filename.join(",");
	   return_str=pic_str+"@"+text_str+"@"+link_str+"@"+org_filename_str;
	   window.close();window.returnValue=return_str;
   });
 // window.onbeforeunload=function(){
    //   $("#back_btn").click();
 // }
   
});
delTr=function(o){
  // var o=event.srcElement?event.srcElement:event.target;
  if($("#content tr").length<=4){alert('不能删除');return false;}
   $(o).parent().parent().remove();
   
}
</script>
</head>
<body>
<center>
<p>&nbsp;</p>
<table  border="0" cellspacing="10" cellpadding="0" id="content">
  <tr>
    <td colspan="4" align="center">
      <input type="button" name="add" id="add" value="添  加">
      <input type="submit" name="back_btn" id="back_btn" value="确  认"><b style="margin-left:5px;">点击"添加" 上传更多图片</b></td>
  </tr>
  
  <tr>
    <td>
    <table border="0" cellspacing="0" cellpadding="0">
    <tr><td align="center"><span style="margin-right:5px;width:100px;"></span><img src="__PUBLIC__/images/admin/no.jpg" name="thumb" width="50" height="50" title="点击查看大图"  style="cursor:pointer; vertical-align:middle;" onclick="var v=this.src;window.open(v);"/></td><td><input type="text" size="20" name="pic_path"/><input type="button"  value="上  传" onClick="var v=window.showModalDialog('__APP__/Admin/Public/upload/is_thumb/{$Think.get.is_thumb}/thumb_w/{$Think.get.thumb_w}/thumb_h/{$Think.get.thumb_h}/thumb_label/{$Think.get.thumb_label}/thumb_type/{$Think.get.thumb_type}/is_wm/{$Think.get.is_wm}/wm_type/{$Think.get.wm_type}/wm_pos/{$Think.get.wm_pos}','','dialogWidth=400px;dialogHeight=180px');<literal>if(v!==undefined){var v_arr=v.split('|');</literal>if({$Think.get.is_show_org_filename}==1)<literal>{$(this).parent().prev().find('span').text('原始文件名:'+v_arr[1]);}$(this).prev('input').val(v_arr[0]);$(this).parent().prev().find('img').attr('src','__ROOT__/'+v_arr[0]);}</literal>"/></td></tr>
    </table>  
    </td>
    
    <td>图片文字:<input type="text" name="pic_text"></td>
    <td>图片连接:<input type="text" name="pic_link" ></td>
    <td><input type="button" name="del" id="del" value="删除" onClick="delTr(this);"></td>
  </tr>
  <tr>
    <td colspan="4"><div align="center">{$setup.webname}&copy;{$setup.weburl}</div></td>
  </tr>
</table>
<p>&nbsp;</p>
</center>
</body>
</html>
